@extends('admin::layouts.master')
@section('title')
    {{$title}}
@endsection
@section('tab')
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form">
                <input type="hidden" name="id" value="{{$arr_data['id']}}">
                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>规格属性</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" value="{{$arr_data['name']}}" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>排序</label>
                    <div class="layui-input-inline">
                        <input type="text" name="sort" value="{{$arr_data['sort']}}" lay-verify="sort" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>状态</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="status" value="2" title="禁用" @if($arr_data['status'] != 1) checked @endif>
                        <input type="radio" name="status" value="1" title="启用" @if($arr_data['status'] == 1) checked @endif>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label"></label>
                    <button class="layui-btn" lay-filter="add" lay-submit="">编辑</button>
                </div>
            </form>
        </div>
    </div>
@endsection

@section('tab_js')
<script>

    layui.use(['form', 'layer', 'jquery'], function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //自定义验证规则
        form.verify({
            sort: function(value) {
                if (value){
                    if (!(/(^[1-9]\d*$)/.test(value))) {
                        return '请输入正整数';
                    }
                } else{
                    return '必填不能为空';
                }
            },
        });

        //监听提交
        form.on('submit(add)', function (data) {
            $.ajax({
                url: js_url('admin-goods-specs-cate-update'),
                type: 'post',
                data: data.field,
                dataType: "json",
                success: function (result) {
                    if (result.state === 0) {
                        layer.msg(result.msg, {time: 600, icon: 6}, function () {
                            //关闭当前frame
                            xadmin.close();
                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                        });
                    } else {
                        layer.msg(result.msg, {time: 600, icon: 5});
                    }
                }
            });

            return false;
        });

    });
</script>
@endsection




